package com.mypan.controller;

import com.alibaba.fastjson2.JSONObject;
import com.mypan.service.FileService;
import com.mypan.uitls.FileUtil;
import com.mypan.vo.FileVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@CrossOrigin
@Transactional
public class FileController {
    @Autowired
    FileService fileService;

    @GetMapping("/getList")
    public JSONObject getList(
            @RequestParam(value = "path", defaultValue = "", required = false) String path,
            @RequestParam(value = "name", defaultValue = "", required = false) String name,
            @RequestParam(value = "type", defaultValue = "", required = false) Integer type) {
        return fileService.getDirFileList(path);
    }
    @GetMapping("/text")
    public String readText(@RequestParam("id") String id){
        return fileService.getTextById(id);
    }
}
